table(survey$union.other)
table(survey$F4_4) # not sure
survey[survey$F4_4 == 1, c("union.self", "union.other", "F4_3")]
survey$union.self[survey$F4_4 == 1] <- "Not Sure"
survey$union.other[survey$F4_4 == 1] <- "Not Sure"
survey$union.self <- factor(survey$union.self)
survey$union.other <- factor(survey$union.other)
table(survey$union.self)
table(survey$union.other)
# employment (employed)
survey$employed <- NA
# occupation COMBINED
survey$occupation <- recode(survey$F1,
`1` = "Professional",
`2` = "Manager, official",
`3` = "Proprietor (small business)",
`4` = "Clerical worker",
`5` = "Sales worker",
`6` = "Skilled craftsman, foreman",
`7` = "Operative, unskilled laborer (except farm)",
`8` = "Service worker",
`9` = "Farmer, farm manager, farm laborer",
`10` = "Student",
`11` = "Housewife",
`12` = "Military service",
`13` = "Unemployed",
`14` = "Retired",
`15` = "Welfare",
`16` = "Disabled",
`17` = "Other (specify)",
`18` = "Not sure")
table(survey$occupation)
survey$occupation <- factor(survey$occupation)
# household size (hhsize)
survey$hhsize <- NA
# education (educ)
table(survey$F3)
survey$educ <- recode(survey$F3,
`1` = "Less than high school",
`2` = "High school graduate",
`3` = "Some college",
`4` = "College graduate",
`5` = "Post graduate",
`6` = "Not sure")
survey$educ <- factor(survey$educ, levels = c("Less than high school", "High school graduate",
"Some college", "College graduate", "Post graduate",
"Not sure"),
labels =  c("Less than high school", "High school graduate",
"Some college", "College graduate", "Post graduate",
"Not sure"),
ordered = TRUE)
table(survey$educ)
# household income (income)
survey$income <- recode(survey$F10,
`1` = "7,500 or less",
`2` = "7,501 to 15,000",
`3` = "15,001 to 25,000",
`4` = "25,001 to 35,000",
`5` = "35,001 to 50,000",
`6` = "50,001 to 75,000",
`7` = "75,001 to 100,000",
`8` = "100,001 and over",
`9` = "Not sure")
survey$income <- factor(survey$income,
levels = c("7,500 or less","7,501 to 15,000",
"15,001 to 25,000",
"25,001 to 35,000",
"35,001 to 50,000",
"50,001 to 75,000",
"75,001 to 100,000",
"100,001 and over",
"Not sure"),
labels = c("7,500 or less","7,501 to 15,000",
"15,001 to 25,000",
"25,001 to 35,000",
"35,001 to 50,000",
"50,001 to 75,000",
"75,001 to 100,000",
"100,001 and over",
"Not sure"))
table(survey$income)
# age
survey$age <- recode(survey$F2,
`1` = "18 to 20",
`2` = "21 to 24",
`3` = "25 to 29",
`4` = "30 to 34",
`5` = "35 to 39",
`6` = "40 to 44",
`7` = "45 to 49",
`8` = "50 to 64",
`9` = "65 to 74",
`10` = "75 and over",
`11` = "Not sure") # in codebook as x, but values of F2 variable suggest otherwise
survey$age <- factor(survey$age,
levels = c("18 to 20",
"21 to 24",
"25 to 29",
"30 to 34",
"35 to 39",
"40 to 44",
"45 to 49",
"50 to 64",
"65 to 74",
"75 and over",
"Not sure"),
labels = c("18 to 20",
"21 to 24",
"25 to 29",
"30 to 34",
"35 to 39",
"40 to 44",
"45 to 49",
"50 to 64",
"65 to 74",
"75 and over",
"Not sure"))
table(survey$age)
# race
survey$race <- recode(survey$F13,
`1` = "White",
`2` = "Black",
`3` = "Asian or Pacific Islander",
`4` = "American Indian or Alaskan native",
`5` = "Not sure")
# additional variable exists for Hispanic origin
survey$race <- factor(survey$race)
summary(survey$race)
# politics (party)
survey$party <- recode(survey$F7,
`1` = "Republican",
`2` = "Democrat",
`3` = "Independent",
`4` = "Other (vol.)",
`5` = "Not sure")
survey$party <- factor(survey$party)
table(survey$party)
# politics (ideology)
survey$ideology <- recode(survey$F6,
`1` = "Conservative",
`2` = "Moderate",
`3` = "Liberal",
`4` = "Not sure")
survey$ideology <- factor(survey$ideology)
table(survey$ideology)
summary(survey$S1)
survey$gender <- factor(dplyr::recode(survey$S1,
`1` = "Male",
`2` = "Female"))
summary(survey$gender)
# religion
survey$religion <- recode(survey$F5A,
`1` = "Protestant",
`2` = "Catholic",
`3` = "Jewish",
`4` = "Other (specify)",
`5` = "None (vol.)",
`6` = "Not sure")
survey$religion <- factor(survey$religion)
table(survey$religion)
# subset
survey_891105 <- survey[,c("pid", "study", "year", "urban", "region", "hh",
"inequality", "inequality.variable", "union.self", "union.other",
"employed", "occupation", "hhsize", "educ", "income",
"age", "race", "party", "ideology", "gender", "religion")]
summary(survey_891105)
# save file
saveRDS(survey_891105, file = "survey_891105.rds")
setwd("~/Dropbox/Perception_Inequality_wHannah/Survey Files/File for Ryan/Harris 1990 Business Week National Issues Survey, study no. 901209")
library(dplyr)
survey <- read.table("harris_s901209_spss.tab", header = TRUE)
### fix everything below for this survey
# pid
survey$pid <- c(1:nrow(survey))
# study
survey$study <-"901209"
# study year (year)
survey$year <- 1990
# geographic data (urban)
survey$urban <- NA
# geographic data (region)
survey$region <- NA
# respondent head of household (hh)
survey$hh <- NA
# increasing inequality (inequality)
summary(survey$Q4_2)
survey$inequality <- recode(as.character(survey$Q4_2),
`1` = "Feel",
`2` = "Don't Feel",
`3` = "Not Sure")
survey$inequality <- factor(survey$inequality)
summary(survey$inequality)
table(survey$Q4_2)
# inequality variable (inequality.variable)
survey$inequality.variable <- 1
# union (union.self)
table(survey$F3_1)
survey$union.self <- recode(survey$F3_1,
`0` = "No",
`1` = "Yes")
table(survey$union.self)
survey$union.other <- recode(survey$F3_2,
`0` = "No",
`1` = "Yes")
table(survey$union.other)
table(survey$F3_4) # not sure
survey[survey$F3_4 == 1, c("union.self", "union.other", "F3_3")]
survey$union.self[survey$F3_4 == 1] <- "Not Sure"
survey$union.other[survey$F3_4 == 1] <- "Not Sure"
survey$union.self <- factor(survey$union.self)
survey$union.other <- factor(survey$union.other)
table(survey$union.self)
table(survey$union.other)
# employment (employed)
survey$employed <- NA
# occupation
survey$occupation <- NA
# household size (hhsize)
survey$hhsize <- NA
# education (educ)
table(survey$F2)
survey$educ <- recode(survey$F2,
`1` = "Less than high school",
`2` = "High school graduate",
`3` = "Some college",
`4` = "College graduate",
`5` = "Post graduate",
`6` = "Not sure")
survey$educ <- factor(survey$educ, levels = c("Less than high school", "High school graduate",
"Some college", "College graduate", "Post graduate",
"Not sure"),
labels =  c("Less than high school", "High school graduate",
"Some college", "College graduate", "Post graduate",
"Not sure"),
ordered = TRUE)
table(survey$educ)
# household income (income)
survey$income <- recode(survey$F9,
`1` = "7,500 or less",
`2` = "7,501 to 15,000",
`3` = "15,001 to 25,000",
`4` = "25,001 to 35,000",
`5` = "35,001 to 50,000",
`6` = "50,001 to 75,000",
`7` = "75,001 to 100,000",
`8` = "100,001 and over",
`9` = "Not sure")
survey$income <- factor(survey$income,
levels = c("7,500 or less","7,501 to 15,000",
"15,001 to 25,000",
"25,001 to 35,000",
"35,001 to 50,000",
"50,001 to 75,000",
"75,001 to 100,000",
"100,001 and over",
"Not sure"),
labels = c("7,500 or less","7,501 to 15,000",
"15,001 to 25,000",
"25,001 to 35,000",
"35,001 to 50,000",
"50,001 to 75,000",
"75,001 to 100,000",
"100,001 and over",
"Not sure"))
table(survey$income)
# age
survey$age <- recode(survey$F1,
`1` = "18 to 20",
`2` = "21 to 24",
`3` = "25 to 29",
`4` = "30 to 34",
`5` = "35 to 39",
`6` = "40 to 44",
`7` = "45 to 49",
`8` = "50 to 64",
`9` = "65 to 74",
`10` = "75 and over",
`11` = "Not sure") # in codebook as x, but values of F2 variable suggest otherwise
survey$age <- factor(survey$age,
levels = c("18 to 20",
"21 to 24",
"25 to 29",
"30 to 34",
"35 to 39",
"40 to 44",
"45 to 49",
"50 to 64",
"65 to 74",
"75 and over",
"Not sure"),
labels = c("18 to 20",
"21 to 24",
"25 to 29",
"30 to 34",
"35 to 39",
"40 to 44",
"45 to 49",
"50 to 64",
"65 to 74",
"75 and over",
"Not sure"))
table(survey$age)
# race
survey$race <- recode(survey$F12A,
`1` = "White",
`2` = "Black",
`3` = "Asian or Pacific Islander",
`4` = "American Indian or Alaskan native",
`5` = "Not sure")
# additional variable exists for Hispanic origin
survey$race <- factor(survey$race)
summary(survey$race)
# politics (party)
survey$party <- recode(survey$F6,
`1` = "Republican",
`2` = "Democrat",
`3` = "Independent",
`4` = "Other (vol.)",
`5` = "Not sure")
survey$party <- factor(survey$party)
table(survey$party)
# politics (ideology)
survey$ideology <- recode(survey$F5,
`1` = "Conservative",
`2` = "Moderate",
`3` = "Liberal",
`4` = "Not sure")
survey$ideology <- factor(survey$ideology)
table(survey$ideology)
# gender, "original data"
table(survey$S1)
survey$gender <- factor(recode(survey$S1,
`1` = "Male",
`2` = "Female"))
summary(survey$gender)
# religion
survey$religion <- recode(survey$F4A,
`1` = "Protestant",
`2` = "Catholic",
`3` = "Jewish",
`4` = "Other",
`5` = "None (vol.)",
`6` = "Not sure")
survey$religion <- factor(survey$religion)
table(survey$religion)
# subset
survey_901209 <- survey[,c("pid", "study", "year", "urban", "region", "hh",
"inequality", "inequality.variable", "union.self", "union.other",
"employed", "occupation", "hhsize", "educ", "income",
"age", "race", "party", "ideology", "gender", "religion")]
summary(survey_901209)
setwd("~/Dropbox/Perception_Inequality_wHannah/Survey Files/File for Ryan/Harris 1991 Public Opinion Survey, study no. 911108")
library(dplyr)
survey <- read.table("harris_s911108_spss.tab", header = TRUE)
### fix everything below for this survey
# pid
survey$pid <- c(1:nrow(survey))
# study
survey$study <-"911108"
# study year (year)
survey$year <- 1991
# geographic data (urban)
survey$urban <- NA
# geographic data (region)
survey$region <- NA
# respondent head of household (hh)
survey$hh <- NA
# increasing inequality (inequality)
summary(survey$Q2_C)
survey$inequality <- recode(as.character(survey$Q2_C),
`1` = "Feel",
`2` = "Don't Feel",
`3` = "Not Sure")
survey$inequality <- factor(survey$inequality)
summary(survey$inequality)
table(survey$Q2_C)
# inequality variable (inequality.variable)
survey$inequality.variable <- 1
# union (union.self)
table(survey$F3_1)
survey$union.self <- recode(survey$F3_1,
`0` = "No",
`1` = "Yes")
table(survey$union.self)
survey$union.other <- recode(survey$F3_2,
`0` = "No",
`1` = "Yes")
table(survey$union.other)
table(survey$F3_4) # not sure
survey[survey$F3_4 == 1, c("union.self", "union.other", "F3_3")]
survey$union.self[survey$F3_4 == 1] <- "Not Sure"
survey$union.other[survey$F3_4 == 1] <- "Not Sure"
survey$union.self <- factor(survey$union.self)
survey$union.other <- factor(survey$union.other)
table(survey$union.self)
table(survey$union.other)
# employment (employed)
survey$employed <- NA
# occupation
survey$occupation <- NA
# household size (hhsize)
survey$hhsize <- NA
# education (educ)
table(survey$F2)
survey$educ <- recode(survey$F2,
`1` = "Less than high school",
`2` = "High school graduate",
`3` = "Some college",
`4` = "College graduate",
`5` = "Post graduate",
`6` = "Not sure")
survey$educ <- factor(survey$educ, levels = c("Less than high school", "High school graduate",
"Some college", "College graduate", "Post graduate",
"Not sure"),
labels =  c("Less than high school", "High school graduate",
"Some college", "College graduate", "Post graduate",
"Not sure"),
ordered = TRUE)
table(survey$educ)
# household income (income)
survey$income <- recode(survey$F8,
`1` = "7,500 or less",
`2` = "7,501 to 15,000",
`3` = "15,001 to 25,000",
`4` = "25,001 to 35,000",
`5` = "35,001 to 50,000",
`6` = "50,001 to 75,000",
`7` = "75,001 to 100,000",
`8` = "100,001 and over",
`9` = "Not sure")
survey$income <- factor(survey$income,
levels = c("7,500 or less","7,501 to 15,000",
"15,001 to 25,000",
"25,001 to 35,000",
"35,001 to 50,000",
"50,001 to 75,000",
"75,001 to 100,000",
"100,001 and over",
"Not sure"),
labels = c("7,500 or less","7,501 to 15,000",
"15,001 to 25,000",
"25,001 to 35,000",
"35,001 to 50,000",
"50,001 to 75,000",
"75,001 to 100,000",
"100,001 and over",
"Not sure"))
table(survey$income)
# age
survey$age <- recode(survey$F1,
`1` = "18 to 20",
`2` = "21 to 24",
`3` = "25 to 29",
`4` = "30 to 34",
`5` = "35 to 39",
`6` = "40 to 44",
`7` = "45 to 49",
`8` = "50 to 64",
`9` = "65 to 74",
`10` = "75 and over",
`11` = "Not sure") # in codebook as x, but values of F2 variable suggest otherwise
survey$age <- factor(survey$age,
levels = c("18 to 20",
"21 to 24",
"25 to 29",
"30 to 34",
"35 to 39",
"40 to 44",
"45 to 49",
"50 to 64",
"65 to 74",
"75 and over",
"Not sure"),
labels = c("18 to 20",
"21 to 24",
"25 to 29",
"30 to 34",
"35 to 39",
"40 to 44",
"45 to 49",
"50 to 64",
"65 to 74",
"75 and over",
"Not sure"))
table(survey$age)
# race
survey$race <- recode(survey$F10,
`1` = "White",
`2` = "Black",
`3` = "Asian or Pacific Islander",
`4` = "American Indian or Alaskan native",
`5` = "Not sure")
# additional variable exists for Hispanic origin
survey$race <- factor(survey$race)
summary(survey$race)
# politics (party)
survey$party <- recode(survey$Q5A,
`1` = "Republican",
`2` = "Democrat",
`3` = "Independent",
`4` = "Other (vol.)",
`5` = "Not sure")
survey$party <- factor(survey$party)
table(survey$party)
# politics (ideology)
survey$ideology <- recode(survey$F5,
`1` = "Conservative",
`2` = "Moderate",
`3` = "Liberal",
`4` = "Not sure")
survey$ideology <- factor(survey$ideology)
table(survey$ideology)
